package com.idbk.chargestation.amap.base;

import android.graphics.BitmapFactory;
import android.view.View;

import com.amap.api.maps.AMap;
import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.MyLocationStyle;
import com.amap.api.services.geocoder.GeocodeResult;
import com.amap.api.services.geocoder.GeocodeSearch;
import com.amap.api.services.geocoder.RegeocodeResult;
import com.idbk.chargestation.R;

/**
 * 一次定位及解析所在的地理位置基类
 * Created by zhx on 2017/8/25.
 */

public class BaseMapGeographyActivity extends BaseMapViewActivity
        implements GeocodeSearch.OnGeocodeSearchListener ,View.OnClickListener, AMap.OnCameraChangeListener {

    //地理编码相关
    public GeocodeSearch mGeocodeSearch;

    public void setCameraChangeListener() {
        aMap.setOnCameraChangeListener(this);//设置视觉移动监听
    }

    public void initLocationStyle() {
        if (mapView != null) {
            //定位小蓝点--从高德地图5.1开始
            MyLocationStyle myLocationStyle;
            myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点，定位点依照设备方向旋转，并且会跟随设备移动。（1秒1次定位）如果不设置myLocationType，默认也会执行此种模式。
            myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔，只在连续定位模式下生效，单次定位模式下不会生效。单位为毫秒。
            myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATE);//连续定位、蓝点不会移动到地图中心点，地图依照设备方向旋转，并且蓝点会跟随设备移动。
            //自定义定位图标
            BitmapDescriptor bd = BitmapDescriptorFactory
                    .fromBitmap(BitmapFactory
                            .decodeResource(getResources(), R.drawable.location_marker));
            myLocationStyle.myLocationIcon(bd);
            //
            aMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style
            aMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点，false表示隐藏定位蓝点并不进行定位，默认是false。
        }
    }

    public void initGeocodeSearch() {
        mGeocodeSearch = new GeocodeSearch(this);
        mGeocodeSearch.setOnGeocodeSearchListener(this);
    }


    @Override
    public void onRegeocodeSearched(RegeocodeResult regeocodeResult, int i) {

    }

    @Override
    public void onGeocodeSearched(GeocodeResult geocodeResult, int i) {

    }

    @Override
    public void onClick(View v) {

    }

    @Override
    public void onCameraChange(CameraPosition cameraPosition) {

    }

    @Override
    public void onCameraChangeFinish(CameraPosition cameraPosition) {

    }
}
